<?php
define('o', 0); //声明可以访问 
// 载入初始化且必须在任何输出之前包括HTML标签
require_once('./include/initialize.php');
    if (empty($_GET['id'])) {
        header('Location:../');
        die;
    }else{
        if(!is_integer((integer)$_GET['id'])){
            $_GET['id'] = 1;
            $goods_id = $_GET['id'];
        }else{
            $goods_id = $_GET['id'];
        }
        if($goods_id<1){
            $goods_id = 1;
        }
        
        if (!empty($_SERVER['HTTP_REFERER'])) {
            setcookie("src",$_SERVER['HTTP_REFERER']);
        }else{
            setcookie("src",$_SERVER['REQUEST_URI']);
        }

        $sql = "SELECT goods.goods_id AS goods_id , goods.goods_name AS goods_name , goods.goods_image AS goods_image , class1.class_name AS g_type , class2.class_name AS g_class ,type_name,message.message_val AS message_val ,goods.goods_type AS goods_type ,type.type_id AS type_id FROM xxx_goods AS goods LEFT JOIN xxx_class AS class1 ON goods.goods_type = class1.class_id LEFT JOIN xxx_class AS class2 ON goods.goods_class = class2.class_id LEFT JOIN xxx_type AS type ON goods_keymodel = type_father_id LEFT JOIN  xxx_message AS message ON message.goods_id = goods.goods_id AND message.type_id = type.type_id WHERE goods.goods_id = $goods_id";
        $model = new model("xxx_goods");
        $temp = $model->query($sql, array('goods_id', 'goods_name',"goods_image", 'g_type', 'g_class' ,'type_name','message_val','goods_type','type_id'), $count);
        // $temp['count'] = $count;
        $model->close();
        if (count($temp)<=1) {
            $error = "抱歉哦！没有找到你要的页面 404";
            include(ROOT . "/error.php");
            die;
        }
        $message = array();
        $mainmessage = array();
        foreach($temp as $value){
            $mainmessage['goods_id']    = $value['goods_id'];
            $mainmessage['goods_name']  = $value['goods_name'];
            $mainmessage['g_type']      = $value['g_type'];
            $mainmessage['g_class']     = $value['g_class'];
            $mainmessage['goods_image'] = $value['goods_image'];

            $message[] = array($value['type_name'],
                               trim($value['message_val']) == null ?
                               '暂无信息' : $value['message_val'],
                               'count'=>strlen($value['message_val']),
                               $value['type_id']
                               );
        }

        //取需要排序的列
        foreach ($message as $key => $row) {
            $volume[$key]  = $row['count'];
        }
        // 根据上面取出的列进行排序
        array_multisort($volume,SORT_ASC,$message);
        function sole($vals,&$message){
            foreach($message as $val){
                if($val[0] == $vals){
                    return $val[1] == "暂无信息" ? "" : $val[1];
                }
            }
        }
        $sql = "SELECT * from xxx_editlog AS editlog LEFT JOIN xxx_user AS user ON user.user_id = editlog.user_id LEFT JOIN xxx_type AS type ON editlog.key_id = type.type_id where editlog.goods_id='$goods_id' AND editlog_examine = 0 order by  editlog.editlog_good desc, editlog.editlog_error asc ,editlog.editlog_time desc";
        $model = new model("xxx_editlog");
        $temp = $model->query($sql, array('editlog_id', 'key_id','type_id','type_name', 'user_id','user_name',"editlog_operate", 'editlog_time', 'editlog_usercontent' ,'editlog_srctext','editlog_text','editlog_examine','editlog_examine_time','editlog_examine_user_id','editlog_good','editlog_error'), $count);
        $model->close();
        // print_r($temp);
        $data = array();
        $i =0;
        if (!empty($temp)) {
            foreach ($temp as $key => $value) {
                $data[$i]['user_name'] = $value['user_name'];
                $data[$i]['type_name'] = $value['type_name'];
                $data[$i]['editlog_operate'] = $value['editlog_operate'];
                $data[$i]['editlog_usercontent'] = $value['editlog_usercontent'];
                $data[$i]['editlog_srctext'] = $value['editlog_srctext'];
                $data[$i]['editlog_text'] = $value['editlog_text'];
                $data[$i]['editlog_examine'] = $value['editlog_examine'];
                $data[$i]['editlog_time'] = $value['editlog_time'];
                $data[$i]['editlog_good'] = $value['editlog_good'];
                $data[$i]['editlog_error'] = $value['editlog_error'];
                $data[$i]['editlog_id'] = $value['editlog_id'];
                $data[$i]['key_id'] = $value['key_id'];

                // $data[''] = $value[''];
                $i++;
            }
        }
        
        // print_r($data);
    }
    setcookie("src",$_SERVER['REQUEST_URI']);
    session_start();
    if(empty($_SESSION['time'])){
        if (!empty($_SERVER['HTTP_REFERER'])) {
                setcookie("src",$_SERVER['REQUEST_URI']);
            }else{
                setcookie("src",$_SERVER['REQUEST_URI']);
            }
    }else{
        setcookie('PHPSESSID',session_id(),time()+3600*1);
    }

?>

<!DOCTYPE HTML>
<html>
 <head>
  <title> <?php echo $mainmessage['g_class'] . ' '. $mainmessage['g_type'].' '.$mainmessage['goods_name']; ?>  爱遥控 - 在线电视机遥控器型号对照查询 </title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="keyword" content="爱遥控 遥控器大全 遥控器查询 搜索遥控器 空调遥控器 彩电遥控器 遥控器对照表 国外彩电遥控器 国内彩电遥控器 yaokongqi 万能遥控器" />
 <meta name="description" content=" 爱遥控为广大网友提供更方便的遥控器查询系统，一站式遥控器信息服务,遥控器,机顶盒遥控器,学习型遥控器,单功能遥控器,空调遥控器,电视机遥控器,RF-射频遥控器,下载型遥控器,普通遥控器，永久免费查询。" />
  <link rel="stylesheet" type="text/css" href="/css/in.css" />
  <!--[if gte IE 7]><link rel="stylesheet" type="text/css" href="/css/augment-ie7.css" /><![endif]--> 
  <!--[if gte IE 8]><link rel="stylesheet" type="text/css" href="/css/augment-ie8.css" /><![endif]-->
  <!--[if !IE]><!--><link rel="stylesheet" type="text/css" href="/css/augment.css" /><!--<![endif]--> 
<script src="/js/ajax.js"></script>
<script src="/js/select.js"></script>
<script src="/js/augment.js"></script>
 </head>
 <body>
<div id="bodys">
        <div id="topmany">
                <div id="top"><a href="."><div id="logo"></div></a></div>
                        <div id="left">
                                <form id="myform"  action="debate.php" method="get">
                                <div>
                                <div onmouseover="this.style.display='none'" style="width:330px;;position:absolute;z-index:2;line-height:25px;height:25px;float:left;background:#666666;color:#FFFFFF;margin-top:10px;margin-left:5px;">请输入彩电型号或者遥控器信息...</div>
                                </div>
                                <div id="edlin"><input id="edlintext" name="w" type="text" maxlength="30" size="30" value="" /></div>

                                </form>
                                <div id="select" onclick="search()">Search</div>
                        </div>

                <div id="among">

                        <div id="messagediv">
                                <div id="titlediv"><a href="./show.php?id=<?php echo $goods_id; ?>"><?php echo $mainmessage['g_class'] . ' '. $mainmessage['g_type'].' '.$mainmessage['goods_name']; ?></a></div>
                                <!-- <div id="hr"></div> -->
                                <div id="message">
                                        <?php if(!empty($message)){ foreach($message as $val){ ?>
                                        <div class="text">
                                                <div class="text-left">
                                                <?php echo $val[0]; ?>
                                                ：</div>
                                                <div class="text-right">
                                                <?php echo $val[1]; ?>
                                                </div>
                                        </div>
                                        <?php }} ?>
                                </div>
                        </div>
                </div>
                <div class="comment">
                <form method="post" action="control.php" id="assess">
                    <input id="control" type="hidden" name="control" value="assess">
                    <input id="messageid" type="hidden" name="messageid" value="">
                    <input id="typeid" type="hidden" name="typeid" value="">
                    <input id="goodbay" type="hidden" name="goodbay" value="">
                </form>
                <form method="post" action="control.php" id="examine">
                    <input id="control" type="hidden" name="control" value="examine">
                    <input id="messageid1" type="hidden" name="messageid" value="">
                    <input id="examineval" type="hidden" name="examineval" value="">
                </form>

                <?php foreach($data as $value){ ?>
                    <div id="comment-text" >
                    <?php 
                        if ($value['editlog_examine'] == 0) {
                        	echo "[待审核] ";
                        }elseif ($value['editlog_examine'] == 1) {
                            echo "[已审核] ";
                        }

                        echo '更新后'.$value['type_name'] .'：';
                        if ($value['editlog_operate'] == "add") {
                            echo sole($value['type_name'],$message).' <span style="color:#FFFFFF;">'. $value['editlog_text'].'</span>';
                        }elseif ($value['editlog_operate'] == "update") {
                            $t = str_replace($value['editlog_usercontent'],'<span style="color:#FFFFFF;">'.$value['editlog_text'].'</span>',sole($value['type_name'],$message));
                            echo $t == "" ?"暂无信息":$t;
                            // echo $value['editlog_text'];
                        }elseif ($value['editlog_operate'] == "delete") {
                            $t = trim(str_replace($value['editlog_text'],"",sole($value['type_name'],$message)),' ');
                            echo $t == "" ?"暂无信息":$t;
                        }
                        // $value['editlog_text'] . sole($value['type_name'],$message); 
                    ?> </div>
                    <div id="hr"></div>
                    <div id="comment-title">
                    <?php
                    	if ($value['editlog_examine'] == 0) {
                        	if (!empty($_SESSION['class'])) {
                                //判断是否是管理员
                        		if ($_SESSION['class'] == 15) {
                                	echo '<span onclick="eseng(this.id,'.$value['editlog_id'].',1)" id="ss'.$value['editlog_id'].'" class="shspan" >审核</span> <span onclick="eseng(this.id,'.$value['editlog_id'].',2)" id="pp'.$value['editlog_id'].'" class="shspan1">屏蔽 </span>';
                            	}
                        	}                            
                        }
                    ?>
                    <span onclick="oseng(this.id,'good',<?php echo $value['editlog_id'];?>,<?php echo $value['key_id'];?>)" id="g<?php echo $value['editlog_id'];?>" class="pg">支持他(<?php echo $value['editlog_good'];?>) </span>
                    <span onclick="oseng(this.id,'bay',<?php echo $value['editlog_id'];?>,<?php echo $value['key_id'];?>)" id="b<?php echo $value['editlog_id'];?>" id="b<?php echo $value['editlog_id'];?>" class="pg">有错误(<?php echo $value['editlog_error'];?>) </span>
                    会员：
                    <?php echo $value['user_name']; ?> <?php if($value['editlog_operate']=="add"){echo '增加';}elseif($value['editlog_operate']=="update"){echo '修改';}elseif($value['editlog_operate']=='delete'){echo "删除";} ?> <?php echo $value['type_name']; if($value['editlog_operate']=="update"){echo ' 将修改内容：' . $value['editlog_usercontent'];} if($value['editlog_operate']=="delete"){echo ' 将删除内容：' . $value['editlog_text'];} ?>
                    </div>
                    <div id="time"><?php echo gmdate('Y-m-d H:i:s',$value['editlog_time']); ?></div>
                    <div style="margin-bottom:10px;"></div>
                <?php } ?>
                
                </div>
                <div id="edit-div">
                <?php                 
                    if(empty($_SESSION['time'])){
                        echo '<div id="mm-login">此功能需<a href="./login.php">登陆</a>,你还没有<a href="./register.php">注册</a>,快去申请吧！</div>';
                    }
                ?>
                    <form id="augment" action="control.php" method="post">
                        <div id="operate">
                            <div id="add-buttom" onclick="butt(this)" onmouseover="show(this)" onmouseout="noshow(this)">增加</div>
                            <div id="delete-buttom" onclick="butt(this)" onmouseover="show(this)" onmouseout="noshow(this)">删除</div>
                            <div id="update-buttom" onclick="butt(this)" onmouseover="show(this)" onmouseout="noshow(this)">修改</div>
                            <div id="list">
                                <select name="type" id="list-select">
                                    <?php foreach($message as $val){ ?>
                                    <option value="<?php echo $val[2] ; ?>"><?php echo $val[0] ; ?></option>
                                    <?php } ?>
                                </select>
                            </div>
                            
                            <input id="operatetext" type="hidden" name="operate" value="add">
                            <input id="control" type="hidden" name="control" value="augment">
                            <input id="times" type="hidden" name="times" value="">
                            <input id="goodsid" type="hidden" name="goodsid" value="<?php echo $goods_id; ?>">
                            <div id="edit-text-min-div">
                                <input id="edit-text-min" maxlength="300" size="300" disabled="disabled" name="edittext" type="text" value="">
                            </div>
                            <div id="save-buttom" onclick="sub()">提交</div>
                        </div>
                        <textarea maxlength="5000" size="5000" name="text" id="edit-text-max"></textarea>
                    </form>
                </div>
        </div>
                <div id="about">
                本站数据来源于网络我们不能保证内容的正确性,通过使用本站内容随之而来的风险与本站无关。本站对非营利性内容产生的任何法律问题及风险不承担任何责任。如果您愿意帮助我们发展为更多的人提供帮助您也可以向我们的数据库<a href="/add.php">添加内容</a>, 当使用本站时，代表您已接受了本站的<a href="/about.php">使用条款</a>和<a href="/about.php">隐私条款</a>。 <a href="http://www.miibeian.gov.cn/">赣ICP备13006249</a> 版权所有，保留一切权利。
                </div>
</div>

<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "//hm.baidu.com/hm.js?6668e0a07b0b9f2d8464728cf2d59d33";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>

</body>
</html>
